package com.ruoyi.fys.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.fys.domain.CulturalRelics;
import com.ruoyi.fys.service.ICulturalRelicsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 文物列表Controller
 * 
 * @author ruoyi
 * @date 2025-09-01
 */
@RestController
@RequestMapping("/fys/culturals")
public class CulturalRelicsController extends BaseController
{
    @Autowired
    private ICulturalRelicsService culturalRelicsService;

    /**
     * 查询文物列表列表
     */
    @PreAuthorize("@ss.hasPermi('fys:culturals:list')")
    @GetMapping("/list")
    public TableDataInfo list(CulturalRelics culturalRelics)
    {
        startPage();
        List<CulturalRelics> list = culturalRelicsService.selectCulturalRelicsList(culturalRelics);
        return getDataTable(list);
    }

    /**
     * 导出文物列表列表
     */
    @PreAuthorize("@ss.hasPermi('fys:culturals:export')")
    @Log(title = "文物列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CulturalRelics culturalRelics)
    {
        List<CulturalRelics> list = culturalRelicsService.selectCulturalRelicsList(culturalRelics);
        ExcelUtil<CulturalRelics> util = new ExcelUtil<CulturalRelics>(CulturalRelics.class);
        util.exportExcel(response, list, "文物列表数据");
    }

    /**
     * 获取文物列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('fys:culturals:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(culturalRelicsService.selectCulturalRelicsById(id));
    }

    /**
     * 新增文物列表
     */
    @PreAuthorize("@ss.hasPermi('fys:culturals:add')")
    @Log(title = "文物列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CulturalRelics culturalRelics)
    {
        return toAjax(culturalRelicsService.insertCulturalRelics(culturalRelics));
    }

    /**
     * 修改文物列表
     */
    @PreAuthorize("@ss.hasPermi('fys:culturals:edit')")
    @Log(title = "文物列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CulturalRelics culturalRelics)
    {
        return toAjax(culturalRelicsService.updateCulturalRelics(culturalRelics));
    }

    /**
     * 删除文物列表
     */
    @PreAuthorize("@ss.hasPermi('fys:culturals:remove')")
    @Log(title = "文物列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(culturalRelicsService.deleteCulturalRelicsByIds(ids));
    }
}
